<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>列表过滤器</title>
	</head>
	<body>
		{% set numbers = [3, 4, 1, 2, 8, 5] %}

		<p>{{ numbers | first }}</p> <br>
		<p>{{ numbers | length }}</p> <br>
		<p>{{ numbers | sum }}</p> <br>
		<p>{{ numbers | sort }}</p> <br>
		<p>{{ numbers | join(',') }}</p> <br>

		{% set student_list = [
			{
				'name': 'zhangsan',
				'age': 38,
				'gender': '女'
			},
			{
				'name': 'lisi',
				'age': 69,
				'gender': '男'
			},
			{
				'name': 'wangwu',
				'age': 17,
				'gender': '女'
			}
		] %}
		{# 根据学生年龄排序 #}
		<ul>
			{% for stu in student_list | sort(attribute='age', reverse = False) %}
				<li>{{ stu.name }} {{ stu.age }}</li>
			{% endfor %}

		</ul>
		{# 根据性别分组 #}
		<ul>
			{% for group in student_list | groupby('gender') %}
				<li>{{ group.grouper }}</li>
				{% for stu in group.list %}
					<li>{{ stu.name }} {{ stu.age }}</li>

				{% endfor %}

			{% endfor %}

		</ul>
		{#  取出字典中的某列，组成一个大列表，然后再把列表变成字符串 #}
		<p>{{ student_list | map(attribute = 'name') | join(' - ') }}</p>

		<p>{{ [1,2,3,4,5,6,7,8,9,10] | get_top }}</p> <br>
		<p>{{ [1,2,3,4,5,6,7,8,9,10] | get_qu }}</p> <br>
	</body>
</html>